<?php

namespace backend\controllers;

use Yii;
use common\models\BaseModels;
use common\models\agentUser\AgentUser;
use common\services\agentUser\AgentUserService;


/**
 * CarBrandController implements the CRUD actions for CarBrand model.
 */
class AgentUserController extends BaseExtendController
{

	public $where = ['is_valid = ' . BaseModels::MODEL_IS_VALID];

	public function settings(){
        return array( "title" => Yii::t('app', 'Agent User'),'pk' => 'id', 'model' => new AgentUser());
    }

    public function hook_before_filter(){
        $params  = $this->request->queryParams;

        $search  = [];
        return $search;
    }

    //封号
    public function actionCloseAccount(){
    	$id = Yii::$app->getRequest()->get('id', '');
    	echo $id;exit;
        $model = new AgentUser();
        return $this->render('index', [
                'model' => $model,
            ]);
    }

    //ajax请求修改代理人员的状态
    public function actionUpdateStatus(){
    	//获取ajax传递的值
    	$id 	= Yii::$app->getRequest()->post('id', '');
    	$status = Yii::$app->getRequest()->post('status', '');
    	//返回结果
    	$result = AgentUserService::updateStatus($id,$status);
    	echo json_encode($result);
    	exit;
    }
}
